home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacHack 2000
/
MacHack 2000.toast
/
pc
/
The Hacks
/
Softshoe
/
Lisa's Mac Parts
/
Windows
/
WindowObject.h
< prev
next >
Wrap
Text File
|
2000-06-23
|
5KB
|
143 lines
// WindowObject.h
#ifndef WindowObject_h
#define WindowObject_h
#ifndef __WINDOWS__
#include <Windows.h>
#endif
#ifndef ConstPString_h
#include "ConstPString.h"
#endif
#ifndef Str_h
#include "Str.h"
#endif
#ifndef PointObject_h
#include "PointObject.h"
#endif
#ifndef Rectangle_h
#include "Rectangle.h"
#endif
#ifndef GrafPortObject_h
#include "GrafPortObject.h"
#endif
class RegionObject;
class WindowObject: public WindowRecord
{
private:
// not implemented:
WindowObject( const WindowObject& );
void operator=( const WindowObject& );
WStateData& StateData();
const WStateData& StateData() const;
static WindowObject *DoCheckedCast( const void * );
public:
enum Definition
{
noZoom = documentProc,
dialog = dBoxProc,
plain = plainDBox,
shadowed = altDBoxProc,
noGrowNoZoom = noGrowDocProc,
movableModal = movableDBoxProc,
document = zoomDocProc,
noGrow = zoomNoGrow,
rounded = rDocProc
};
WindowObject( Definition = document, bool withCloseBox = true );
~WindowObject() { CloseWindow( &port ); }
void Select() { SelectWindow( &port ); }
void SendBehind( WindowObject& w ) { ::SendBehind( &port, &w.port ); }
void SendToBack() { ::SendBehind( &port, 0 ); }
uint32 Index() const;
void SetIndex( uint32 );
void Show() { ShowWindow( &port ); }
void Hide() { HideWindow( &port ); }
void SetTitle( ConstPString s ) { SetWTitle( &port, s ); }
void GetTitle( String255& s ) const { GetWTitle( const_cast<WindowPtr>(&port), s ); }
PointObject Position() const { return Port().GlobalBounds().TopLeft(); }
void SetPosition( PointObject p ) { MoveWindow( &port, p.h, p.v, false ); }
void MoveByDragging( PointObject mouse ) { DragWindow( &port, mouse, &Rectangle::big ); }
PointObject Size() const { return Port().LocalBounds().Size(); }
void SetSize( PointObject size ) { SizeWindow( &port, size.h, size.v, true ); }
PointObject SizeByDragging( PointObject mouse,
PointObject minimum,
PointObject maximum );
Rectangle GlobalBounds() const { return Port().GlobalBounds(); }
void SetBounds( Rectangle );
Rectangle UserBounds() const { return StateData().userState; }
void SetUserBounds( Rectangle r ) { StateData().userState = r; }
Rectangle StandardBounds() const { return StateData().stdState; }
void SetStandardBounds( Rectangle r ) { StateData().stdState = r; }
bool TrackZoomInBox( PointObject mouse ) { return TrackBox( &port, mouse, inZoomIn ); }
bool TrackZoomOutBox( PointObject mouse ) { return TrackBox( &port, mouse, inZoomOut ); }
bool TrackCloseBox( PointObject mouse ) { return TrackGoAway( &port, mouse ); }
void ZoomToUserBounds();
void ZoomToStandardBounds();
Rectangle LocalBounds() const { return Port().LocalBounds(); }
int32 RefCon() const { return GetWRefCon( const_cast<WindowPtr>( &port ) ); }
void SetRefCon( int32 r ) { SetWRefCon( &port, r ); }
static WindowObject *Front() { return reinterpret_cast<WindowObject *>( FrontWindow() ); };
WindowObject *Next() { return static_cast<WindowObject *>( nextWindow ); }
bool IsFrontmost() const { return this == Front(); }
GrafPortObject& Port() { return static_cast<GrafPortObject&>( port ); }
const GrafPortObject& Port() const { return static_cast<const GrafPortObject&>( port ); }
int16 Kind() const { return windowKind; }
bool Visible() const { return visible != 0; }
bool Highlighted() const { return hilited != 0; }
bool HasCloseBox() const { return goAwayFlag != 0; }
bool HasZoomBox() const { return spareFlag != 0; }
// These are in global coordinates:
const RegionObject& StructureRegion() const { return *reinterpret_cast<const RegionObject*>( &strucRgn ); }
const RegionObject& ContentRegion() const { return *reinterpret_cast<const RegionObject*>( &contRgn ); }
const RegionObject& InvalidRegion() const { return *reinterpret_cast<const RegionObject*>( &updateRgn ); }
// This is in local coordinates:
const RegionObject& VisibleRegion() const { return *reinterpret_cast<const RegionObject*>( &port.visRgn ); }
int16 TitleWidth() const { return titleWidth; }
ControlHandle FirstControl() const { return reinterpret_cast<ControlHandle>(controlList); }
void SetVisibility( bool visible ) { ShowHide( &port, visible ); }
void SetHighlighting( bool highlighted ) { HiliteWindow( &port, highlighted ); }
GDHandle NearestScreen() const;
GDHandle DeepestScreen() const;
static uint32 CountVisibleWindows();
static uint32 CountVisibleWindows( Rectangle );
Rectangle FrameSize() const;
static WindowObject *CheckedCast( void *p ) { return DoCheckedCast(p); }
static const WindowObject *CheckedCast( const void *p ) { return DoCheckedCast(p); }
};
#endif